/<template>
    <van-pull-refresh v-model="refreshing">
        <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
        >
            <slot></slot>
        </van-list>
    </van-pull-refresh>
</template>

<script>
export default {
    data() {
        return {
            loading: false,
            finished: false,
            refreshing: false,
        }
    },
    props: {
        total: {
            type: Number,
            default: 0,
        },
        listLen: {
            type: Number,
            default: 0,
        }
    },
    methods: {
        onLoad() {
            clearTimeout(this.timer)
            this.timer = setTimeout(() => {
                if (this.refreshing) {
                    this.$emit('onRefreshList') 
                    this.refreshing = false;
                }
                this.$emit('onLoad') 
                this.loading = false;
                if (this.listLen >= this.total) {
                    this.finished = true;
                }
            }, 1000)
        },
    }
}
</script>

<style>
.van-pull-refresh {
    overflow: scroll;
}
</style>